package com.tanhua.sso.controller;

import com.tanhua.sso.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @ClassName: UserInfoController
 * @Author:王晨晗
 * @Description: 用户详细信息模块
 * @Date: 2021/12/27/9:35
 */
@RestController
@RequestMapping("user")
@Slf4j
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    //保存用户详细信息
    @PostMapping("loginReginfo")
    public ResponseEntity loginRefinfo(@RequestHeader("Authorization") String token , @RequestBody Map<String , String > params){
        //调用保存用户详细方法
        userInfoService.saveUserInfo(token , params);
        //返回响应结果
        return ResponseEntity.ok(null);
    }

    //保存用户头像信息
    @PostMapping("loginReginfo/head")
    public ResponseEntity head(@RequestHeader("Authorization") String token , @RequestParam("headPhoto") MultipartFile uploadFile){
        //执行文件上传方法;
        userInfoService.uploadFile(token , uploadFile);
        //响应结果
        return ResponseEntity.ok(null);
    }

}
